﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.WebSockets.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace YSC_Backstage_Web.RestClient
{
    public class ExceptionFillters : ActionFilterAttribute
    {

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var isDefined = false;
            var controllerActionDescriptor = filterContext.ActionDescriptor as ControllerActionDescriptor;
            if (controllerActionDescriptor != null)
            {
                isDefined = controllerActionDescriptor.MethodInfo.GetCustomAttributes(inherit: true)
                  .Any(a => a.GetType().Equals(typeof(ILoginFilterAttribute)));
            }


          

            //    filterContext.Result = new RedirectResult("/Login/Login");

            //if (isDefined) return;
            //if (filterContext.Current.Session.GetString("LoginInfo") == null)
            //{
            //    filterContext.Result = new RedirectResult("/Account/Login");
            //}
            base.OnActionExecuting(filterContext);
        }
   
    }
    /// <summary>
    /// 不需要登陆的地方加个特性
    /// </summary>
    public class NoSignAttribute : ActionFilterAttribute { }

}
